import { getSpecList } from '@/services';
import { RootObject ,Record ,ProdPropValue } from '@/types';
import { Effect, Reducer } from 'umi';

export interface SpecModelState {
  specList:{},
}

export interface SpecModelType {
  namespace: 'spec';
  state: SpecModelState;
  effects: {
    getSpecList: Effect;
  };
  reducers: {
    save: Reducer<SpecModelState>;
  };
}

const specModel: SpecModelType = {
  namespace: 'spec',
  state: {
    specList: {},
  },

  effects: {
    *getSpecList({payload}, {call, put}){
      console.log(payload,'qxh----payload');
        let result = yield call (getSpecList);
        console.log(result,'qxh');
        
      if (result){
        yield put({
          type: 'save',
          payload: {
            specList: result.records
          }
        })
      }
    },
  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};

export default specModel;
